Alibabacloud.com offers a wide variety of articles about springbootservletinitializer, easily find your springbootservletinitializer information here online.
Summary
After reading this article you will grasp the following knowledge points: The role of springapplication and the operation process of Springbootservletinitializer and operation process
PS: This section is slightly boring, if you are not interested in the Springboot startup process, you can skip.
springboot Series : Spring boot Learning Notes deep understanding of Springapplication
@SpringBootApplication public
class Springbootwebdemoapplicatio
flag, otherwise it cannot be accessed, http://localhost : 8080/cat?true=flag This address is not accessible, the correct address is http://localhost:8080/cat?flag=true to be able to access the normal
Headers and params are similar, only the request headers contains a key in order to access the method
b). JSP-Side Code
This JSP only does one thing and displays the value of the ${hi} tag inside the Java class.
5. Running the program
So far,
-xmx128m Xxx.jar, the machine run no problem. But the requirement is to use an external tomcat container instead of tomcat-embed, so check the official documentation as follows:The first step in producing a deployable war file was to provide a springbootservletinitializer subclass and override its C Onfigure method. Doing so makes use of the Spring Framework ' s Servlet 3.0 support and lets you configure your application when it's launched B Y the ser
Preface
The Springboot project is in the process of developing a built-in Tomcat,jetty container, and what happens when the project needs to be released.Only two-step steps are required to modify the startup class, Inherit Springbootservletinitializer, and override the Configure method
/**
* Author: Meet small star
* email:tengxing7452@163.com
* date:17-5-10 * time
: a.m. 10:40
* Describe: Program Entry
*/
@SpringBootApplication
@EnableAutoC
recommended by spring.
The rest is to modify our startup class. We previously started the class as the boot method, and we want to change it to the Tomcat method, of course, the previous boot methods are still used locally.
Public class servletinitializer extends springbootservletinitializer {
@ OverrideProtected springapplicationbuilder configure (springapplicationbuilder application ){Return application. Sources (uloanapplication. Class );}}
This c
Spring Boot war package instance tutorial, springwar
In addition to executable jar packages, Spring Boot also supports traditional war packages. This article describes how to use Spring Boot to build a traditional war package.
Follow these steps to create a war package for Spring Boot:
1. Define the packaging type in pom. xml
2. Add the Spring Boot starter (you can also use parent)
3. Add spring-boot-starter-web dependency
4. Add packaging plug-ins
5. The main class inherits
/dependenciesBuildPluginsPluginGroupidorg.springframework.boot/groupidArtifactidspring-boot-maven-plugin/artifactid/plugin/pluginsFinalnamespringboot_tomcat/finalname/build/projectModify the startup class so that it inherits from the Springbootservletinitializer class, overriding the Configure method, with the following code:Package Com.dalaoyang;Import org.springframework.boot.SpringApplication;Import org.springframework.boot.autoconfigure.SpringBoot
jetty container as follows: PackagedPackaging method:CMD into the project directory, using the MVN Clean Packages command to package, take my project projects as an example:E:\SPRING-BOOT-SAMPLE>MVN Clean PackageYou can append a parameter -dmaven.test.skip=true (-dskiptests) to skip the test.The packaged files are stored in the target directory under the project, such as: Spring-boot-sample-0.0.1-snapshot.jarSpring-boot-sample-0.0.1-snapshot.war If the POM is configured with a war packageIi. de
package for the maven Project
Set
Change
2. Exclude tomcat during packaging.
Set the scope attribute to provided, so that the JAR package is not included in the final WAR, because servers such as Tomcat and Jetty will provide related API classes at runtime.
3. register the startup class
Create ServletInitializer. java, inherit SpringBootServletInitializer, overwrite configure (), and register the startup class Application. When the external web Ap
parameter-dmaven.test.skip=true to skip the test.The packaged files are stored in the target directory under the project, such as: Spring-boot-sample-0.0.1-snapshot.jarSpring-boot-sample-0.0.1-snapshot.war If the POM is configured with a war packageIi. deploy to a Java EE container
Modify the startup class, Inherit Springbootservletinitializer, and override the Configure method
publicclass SpringBootSampleApplication extends
=true to skip the test.The packaged files are stored in the target directory under the project, such as: Spring-boot-sample-0.0.1-snapshot.jarSpring-boot-sample-0.0.1-snapshot.war If the POM is configured with a war packageIi. deploy to a Java EE container
Modify the startup class, Inherit Springbootservletinitializer, and override the Configure method
Public class Springbootsampleapplication extends
Today I want to share with you how do I use Springboot to create a war package that can be deployed in an external tomcat? The internet is a lot of talk, but I still want to record:Springboot official documentation is already clear (85.1 Create a deployable war File)1, the main class inherits Springbootservletinitializer and overrides its configure Method. @SpringBootApplication publicclassapplicationextends spri
Specify the memory to runJava-xms10m-xmx200m-jar Xxx.jarSpring boot is packaged into a war package:Let the Springbootapplication class inherit Springbootservletinitializer and rewrite the Configure method, as follows: @SpringBootApplication public class Springbootapplication extends Springbootservletinitializer {@Override protecte D Springapplicationbuilder Configure (Springapplicationbuilder appl
be accessed. Finally try again the next 2.0.1 version, Springbootservletinitializer class location, all configurations are the same, the project is normal, the individual is not aware of the latest Springboot version 2.0.3 why not, so it is recommended to follow the integration of JSP students use 2.0.1 version.2, SpringbootjspapplicationPackage Com.example.demo;import Org.springframework.boot.springapplication;import Org.springframework.boot.autocon
This article is only about the deployment process, you have to ensure that your program can run in the IDE, first look at the port number set in your application.properties and your server tomcat port number is consistentserver.port=80(I'm not sure if this configuration will affect deployment) look at the entry function for your application@SpringBootApplication@EnableAutoConfiguration(exclude = arrayOf(DataSourceAutoConfiguration::class))class JnaApplication:
the startup class, inherits Springbootservletinitializer, and overrides the Configure method/public
class Springbootstartapplication Extends Springbootservletinitializer {
@Override
protected Springapplicationbuilder Configure ( Springapplicationbuilder builder) {
//note here to point to the application start class return builder.sources that was previously performed with the Main method
under the root package path.
If our project is like the code structure proposed by spring boot, the application class is placed under the root package path. Then we can use @springbootapplication to replace the three annotations above.
Package com.example.myproject;
Import org.springframework.boot.SpringApplication;
Import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication public
class Application {public
static void Main (string[] args) {
Spring
Springbootservletinitializer implementation class and overrides the Configure methodThis will get Servlet3.0 support for the spring framework and can be configured before the app is started by the servlet container. A typical implementation is to have the main class of the application integrate Springbootservletinitializer.This example modifies the Restdemoapplication class as follows: PackageCom.example;ImportOrg.springframework.boot.SpringApplicati
Spring boot can package the project directly into an executable jar file by adding the Spring boot package plugin to the Maven Pom.xmlbuild ; plugins ; plugin ; groupid ; org.springframework.boot; artifactid ; Sprin G-boot-maven-pluginartifactid ; plugin ; plugins , build > This jar file, spring boot embedded tomcat, because can directly through the Jar-jar jar file path, directly run the service, but at this time, if I have the demand, want to directly packaged into a war package, and
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.